home *** CD-ROM | disk | FTP | other *** search
- package test.textui;
-
- import java.lang.reflect.Method;
- import test.framework.Test;
-
- public class TestRunner {
- private static boolean fWait;
-
- public static void main(String[] argv) {
- String testCase = "";
-
- for(int i = 0; i < argv.length; ++i) {
- if (argv[i].equals("-wait")) {
- fWait = true;
- } else {
- testCase = argv[i];
- }
- }
-
- if (testCase.equals("")) {
- System.out.println("Usage: driver [-wait] testCaseName, where name is the name of the TestCase class");
- System.exit(0);
- }
-
- try {
- Class testClass = null;
- Method suiteMethod = null;
- Test suite = null;
-
- try {
- testClass = Class.forName(testCase);
- } catch (Exception var8) {
- System.out.println("Suite class \"" + testCase + "\" not found");
- return;
- }
-
- try {
- suiteMethod = testClass.getMethod("suite");
- } catch (Exception var7) {
- System.out.println("The suite class should have a method named \"suite()\"");
- return;
- }
-
- try {
- suite = (Test)suiteMethod.invoke((Object)null);
- } catch (Exception var6) {
- System.out.println("Could not invoke the suite() method");
- return;
- }
-
- run(suite);
- } catch (Exception var9) {
- System.out.println("Could not create and run test suite");
- }
-
- }
-
- public static void run(Test suite) {
- TextTestResult result = new TextTestResult();
- long startTime = System.currentTimeMillis();
- suite.run(result);
- long endTime = System.currentTimeMillis();
- long runTime = endTime - startTime;
- System.out.println();
- System.out.println("Time: " + runTime / 1000L + "." + runTime % 1000L);
- result.print();
- System.out.println();
- if (fWait) {
- System.out.println("<RETURN> to continue");
-
- try {
- System.in.read();
- } catch (Exception var8) {
- }
- }
-
- }
- }
-